/*
 * @Author: maskMan
 * @LastEditTime: 2024-11-21 12:18:44
 * @Descripttion:模拟数据
 */
import { util } from '@/utils/util';
export default class Mock<T> {
  //创建权限
  constructor(public value: T) {}
  private static _createRoles() {
    const roles: TRole.RoleStruct = {
      代理管理: { 删除权限: true },
      客服管理: { 创建权限: true, 编辑权限: true },
      下属用户: { 查看权限: true },
      直属用户: { 查看权限: true },
      会员权益: { 编辑权限: true },
      奖励设置: { 编辑权限: true },
      游戏分类: { 编辑权限: true },
      礼物商城: { 编辑权限: true },
      操作记录: { 删除权限: true }
    };
    return roles;
  }
  static mock_login(): Promise<TRet.Account> {
    const user: TRet.Account = {
      status: true,
      data: { account: 'admin' },
      msg: '成功',
      token: '111111'
    };
    return Promise.resolve(user);
  }
  static mock_get_manage_roles(): Promise<TRet.Role> {
    const role: TRet.Role = {
      status: true,
      data: {
        manager: {
          account: 'admin',
          ident: 'admin',
          name: '超级管理员',
          parent: '8888',
          phone: '15005490724',
          avaurl: 'https://main.lzmgame.com/headers/head.png',
          lastTime: util.formaDate(7)
        },
        roles: this._createRoles()
      },
      msg: '成功'
    };
    return Promise.resolve(role);
  }
  static mock_update_manage_data(): Promise<TRet.Bool> {
    const data: TRet.Bool = {
      status: true,
      data: true,
      msg: '成功'
    };
    return Promise.resolve(data);
  }
  static mock_get_counts(): Promise<TRet.Counts> {
    const obj = {
      代理管理: {
        totalCount: 10,
        monthCount: 10,
        weekCount: 10,
        dayCount: 10,
        activeCount: 10
      },
      客服管理: {
        totalCount: 10,
        monthCount: 10,
        weekCount: 10,
        dayCount: 10,
        activeCount: 10
      },
      下属用户: {
        totalCount: 10,
        monthCount: 10,
        weekCount: 10,
        dayCount: 10,
        activeCount: 10
      },
      直属用户: {
        totalCount: 10,
        monthCount: 10,
        weekCount: 10,
        dayCount: 10,
        activeCount: 10
      }
    };
    const data: TRet.Counts = {
      status: true,
      data: obj,
      msg: '成功'
    };
    return Promise.resolve(data);
  }
  static mock_get_agent_list(): Promise<TRet.AgentList> {
    const list: Agent[] = [];
    for (let index = 0; index < 20; index++) {
      const agent: Agent = {
        id: index + 1,
        account: '13505395050',
        phone: '13505396020',
        name: '张三家的孩子',
        parent: '13505395050',
        regTime: util.formaDate(7),
        lastTime: util.formaDate(7),
        status: true,
        loginCount: 1,
        customerCount: 2,
        juniorCount: 3,
        directCount: 4
      };
      list.push(agent);
    }
    const lastData: TRet.AgentList = {
      msg: '成功',
      status: true,
      data: list
    };
    return Promise.resolve(lastData);
  }
  static mock_create_agent(rd: TReq.AgentCreat): Promise<TRet.AgentType> {
    const agent: Agent = {
      id: 1,
      account: rd.account,
      phone: rd.phone,
      name: rd.name,
      parent: rd.parent || '',
      regTime: '2222222',
      lastTime: '222222222',
      status: true,
      loginCount: 1,
      customerCount: 2,
      juniorCount: 3,
      directCount: 4
    };
    const data: TRet.AgentType = {
      msg: '成功',
      status: true,
      data: agent
    };
    return Promise.resolve(data);
  }
  static mock_update_agent(rd: TReq.AgentCreat): Promise<TRet.AgentType> {
    const agent: Agent = {
      id: 1,
      account: rd.account,
      phone: rd.phone,
      name: rd.name,
      parent: rd.parent || '',
      regTime: '2222222',
      lastTime: '222222222',
      status: rd.status,
      loginCount: 1,
      customerCount: 2,
      juniorCount: 3,
      directCount: 4
    };
    const data: TRet.AgentType = {
      msg: '成功',
      status: true,
      data: agent
    };
    return Promise.resolve(data);
  }
  static mock_update_agent_status(sd: boolean): Promise<TRet.Bool> {
    const data: TRet.Bool = {
      msg: '成功',
      status: true,
      data: !sd
    };
    return Promise.resolve(data);
  }
  static mock_delete_agent(account: string): Promise<TRet.Bool> {
    const data: TRet.Bool = {
      msg: '成功',
      status: true,
      data: true
    };
    return Promise.resolve(data);
  }
  static mock_logout(): Promise<TRet.Bool> {
    const data: TRet.Bool = {
      msg: '成功',
      status: true,
      data: true
    };
    return Promise.resolve(data);
  }
}
